const { Sequelize } = require('sequelize')
const { MYSQL_HOST, MYSQL_PORT, MYSQL_USER, MYSQL_PWD, MYSQL_DB } = require('../config/config.default')
/**
 * database
 * username
 * password
 */
const seq = new Sequelize(MYSQL_DB, MYSQL_USER, MYSQL_PWD, {
    host: MYSQL_HOST,
    // 数据库类型
    dialect: 'mysql',
    timezone: '+8:00',
    dialectOptions: {
        dateStrings: true,
        useUTC: false,
        typeCast: true
    }

})
// 返回值是一个promise对 象
seq.authenticate().then(() => {
    console.log('数据库连接成功')
}).catch(err => {
    console.log('数据库连接失败', err)
})

module.exports = seq